﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace org.nutilities.common
{
  [DataContract(Name = "response", Namespace = "http://www.nutilities.org/response")]
  public class Response 
  {
    [DataMember(Name = "statusLevel", Order = 0)]
    public StatusLevel Level { get; set; }

    [DataMember(Name = "dateTimeStamp", Order = 1, EmitDefaultValue = false)]
    public DateTime DateTimeStamp { get; set; }

    [DataMember(Name = "statusList", Order = 2, IsRequired = true)]
    public StatusList StatusList { get; set; }

    public Response()
    {
      this.StatusList = new StatusList();      
    }
  }

  [CollectionDataContract(Name = "statusList", Namespace = "http://www.nutilities.org/response", ItemName = "status")]
  public partial class StatusList : List<Status> { }

  [DataContract(Name = "status", Namespace = "http://www.nutilities.org/response")]
  public class Status
  {
    [DataMember(Name = "level", Order = 0)]
    public StatusLevel Level { get; set; }

    [DataMember(Name = "identifier", Order = 1, IsRequired=true, EmitDefaultValue=true)]
    public string Identifier { get; set; }

    [DataMember(Name = "results", IsRequired=true)]
    public Results Results { get; set; }

    [DataMember(Name = "messages", IsRequired = true)]
    public Messages Messages { get; set; }

    public Status()
    {
      this.Messages = new Messages();
      this.Results = new Results();
    }
  }

  [CollectionDataContract(Name = "messages", Namespace = "http://www.nutilities.org/response", ItemName = "message")]
  public partial class Messages : List<string> { }

  [CollectionDataContract(Name = "results", Namespace = "http://www.nutilities.org/response", ItemName = "result")]
  public partial class Results : List<Result> { }

  [DataContract(Name = "result", Namespace = "http://www.nutilities.org/response")]
  public class Result
  {
      [DataMember(Name = "identifier", Order = 0)]
      public string Name { get; set; }

      [DataMember(Name = "value", Order = 1, EmitDefaultValue = false)]
      public string Value { get; set; }
  }

  [DataContract(Name = "statusLevel", Namespace = "http://www.nutilities.org/response")]
  public enum StatusLevel
  {
    [EnumMember]
    Success,
    [EnumMember]
    Warning,
    [EnumMember]
    Error
  }
}
